/**
 * glue.h
 * Glue Layer of CuteTransfer
 *
 * @auther Miles Dung
 * @date May 26 2011
 *
 * This file is part of CuteTransfer project, which
 * released under the GNU GPL v2 or v3 (whichever you like)
 * This project is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY, without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU General Public License for more details.
 */
#ifndef GULE_H_INCLUDED
#define GULE_H_INCLUDED

#include <winsock2.h>
#include <iostream>
#include "ConFile.h"

typedef struct __addr
{
    char ip[16];
    unsigned short port;
    bool operator <(const __addr& t) const
    {
        if (port < t.port)
        {
            return true;
        }
        else
        {
            if (strncmp(ip, t.ip, 16) < 0)
            {
                return true;
            }
        }
        return false;
    }
} addr;

int recv_message(SOCKADDR_IN& sa_in, const char* mes);
int send_message(const char* ip, unsigned short port, const std::string& mes);
int recv_file_request();
int recv_file_init(SOCKADDR_IN& sa_in, FileInfo& finfo);
int recv_file(const std::string& filepath, int progress);
int send_file_request(const char* ip, unsigned short port, const std::string& filepath);
int send_file(const std::string& filepath, int progress);
int send_file_init(SOCKADDR_IN &sa_in, const std::string &filepath, FileInfo& finfo);


#endif // GULE_H_INCLUDED
